using System;
using System.Collections.Generic;
using FixMath;
using UniFramework.Aoe;
using UnityEngine;

namespace UniFramework.Actor
{
	public class LogicAoe : LogicObject
	{
		public AoeObj aoeObj;
		public bool justCreated = true; //是否被视为刚刚创建
		public List<LogicActor> characterInRangeList = new List<LogicActor>(); //在当前范围的角色
		public List<LogicBullet> bulletInRangeList = new List<LogicBullet>(); //在当前范围的子弹
		private GameObject _aoeEffectObj;


		public override void OnCreate()
		{
			if (aoeObj == null) throw new Exception("LogicAoe OnCreate AoeObj is null");
			base.OnCreate();
			GameObject load = Resources.Load<GameObject>($"Skill/{aoeObj.aoeConfig.prefab}");
			_aoeEffectObj = GameObject.Instantiate(load);
			_aoeEffectObj.transform.position = aoeObj.position.ToVector3();
		}

		public override void OnDie()
		{
			base.OnDie();
			if (_aoeEffectObj != null)
			{
				GameObject.Destroy(_aoeEffectObj);
			}

			GameObject.Destroy(gameObject);
		}
	}
}